<template>
  <div class="container">
    <div class="head"></div>
    <ul>
      <li
        :style="{
          backgroundImage:
            item.total_clue_num > item.true_total_num || item.is_sound == 1
              ? `url(${img1})`
              : `url(${img2})`,
        }"
        v-for="(item, index) in list"
        :key="index"
      >
        <!-- <div class="alias_name">{{ item.alias_name }}</div> -->
        <p class="title">{{ item.alias_name }}</p>
        <p class="num">
          <span v-for="(v, k) in item.total_clue_num" :key="k">{{ v }}</span>
          <span class="tiao">tips</span>
        </p>
        <p class="fp">
          已分配：<span style="color: #fff">{{ item.true_total_num }}</span>
          tips
        </p>
      </li>
    </ul>
    <audio ref="audio" id="xyz" src="/static/aotuo.mp3"></audio>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      img1: require("../../assets/imgs/tc2@2x.png"),
      img2: require("../../assets/imgs/red.png"),
      play: false,
      timeS: false,
      audio: "",
    };
  },
  mounted() {
    this.getList();
    setTimeout(() => {
      console.log(this.timeS);
      if (this.timeS) {
        setInterval(() => {
          this.getList();
        }, 5000);
      } else {
        setInterval(() => {
          this.getList();
        }, 1000 * 60 * 3);
      }
    }, 500);
  },
  methods: {
    getList() {
      this.$axios
        .post("http://p.t.fangx999.com/Business/getDataAssignment")
        .then((res) => {
          console.log(res);
          for (let index = 0; index < res.data.length; index++) {
            const item = res.data[index];
            item.total_clue_num = item.total_clue_num.split("");
            if (item.total_clue_num > item.true_total_num) {
              this.$refs.audio.play();
              this.$refs.audio.addEventListener(
                "ended",
                function () {
                  this.$refs.audio.load();
                },
                false
              );
              this.timeS = true;
            } else {
              this.timeS = false;
            }
          }
          this.list = res.data;
        });
    },
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}

.container {
  width: 100%;
  height: 100%;
  background-image: url(../../assets/imgs/20211103105458.png);
  background-size: 100% 100%;
  overflow: auto;
}

.head {
  width: 100%;
  height: 0.5rem;
  background-image: url(../../assets/imgs/head.png);
  background-size: 100% 100%;
}

.container ul {
  list-style: none;
  display: flex;
  /* justify-content: space-between; */
  flex-wrap: wrap;
  margin: 0.1rem 0.2rem 0;
}

.container ul li {
  position: relative;
  width: 23%;
  height: 1.3rem;
  margin-bottom: 0.35rem;
  margin-left: 0.18rem;
  /* background: url(../../assets/imgs/tc2@2x.png) no-repeat; */
  background-size: 100% 100%;
  color: #17f4fc;
  font-size: 0.16rem;
  text-align: center;
}
.container ul li .alias_name {
  position: absolute;
  left: 0.3rem;
  top: 0.2rem;
  color: #fff;
}

.container ul li .title {
  margin-top: 0.2rem;
  font-size: 0.15rem;
}

.container ul li .num span:not(:last-child) {
  display: inline-block;
  border: 2px solid #17f4fc;
  color: #fff;
  padding: 0.03rem 0.03rem;
  margin: 0.1rem 0.03rem;
}

.tiao {
  font-size: 0.12rem;
}

.wrap {
  width: 700px;
  height: 400px;
  position: relative;
}

.wrap img {
  width: 100%;
  height: 100%;
}

.ball {
  width: 20px;
  height: 20px;
  background: red;
  border-radius: 50%;
  position: absolute;
}

.box {
  width: 500px;
  height: 400px;
  overflow: auto;
}

@media screen and (max-width: 1024px) {
  .head {
    width: 100%;
    height: 1.2rem;
    background-image: url(../../assets/imgs/20211103111040.png);
    background-size: 100% 100%;
  }
  .container ul {
    list-style: none;
    display: block;
    margin: 0.1rem 0.5rem 0;
  }
  .container ul li {
    width: 100%;
    height: 5.3rem;
    margin-bottom: 0.55rem;
    background: url(../../assets/imgs/tc2@2x.png) no-repeat;
    background-size: 100% 100%;
    color: #17f4fc;
    font-size: 0.66rem;
    text-align: center;
  }
  .container ul li .alias_name {
    position: absolute;
    left: 0.6rem;
    top: 0.6rem;
    color: #fff;
  }
  .container ul li .title {
    position: relative;
    top: 0.6rem;
    font-size: 0.58rem;
  }
  .container ul li .num span:not(:last-child) {
    display: inline-block;
    border: 2px solid #17f4fc;
    color: #fff;
    padding: 0.15rem 0.1rem;
    margin: 1rem 0.1rem 0.5rem;
  }
  .tiao {
    font-size: 0.52rem;
  }
}
</style>